<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <!--<s:head/>-->
    <title>注册</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link href="${pageContext.request.contextPath}/css/font-awesome.min.css" rel="stylesheet" type="text/css">
	<link href="${pageContext.request.contextPath}/css/bootstrap.min.css" rel="stylesheet" type="text/css">
	<link href="${pageContext.request.contextPath}/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css">
	<link href="${pageContext.request.contextPath}/css/templatemo_style.css" rel="stylesheet" type="text/css">	
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
  	<script type="text/javascript" src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
  <script type="text/javascript">
  	
    $(document).ready(function () {
    	$("#user\\.ualais").blur(function () {
    		//var datastring="user.ualais="+$("#user\\.ualais").val();
    		var options = {
                url: 'validateualais.action',
                type: 'post',
                dataType: 'text',
                data:$("#registform").serialize(),
                success: function (responsedata) {
                    //if (responsedata.length > 0)
                       // $("#responseText").text(responsedata);
                    $('#myModal').modal('show');
                    if(responsedata=="1"){//注册成功
                    	 function jump(count) { 
                			window.setTimeout(function(){ 
                    			count--; 
                    			if(count > 0) { 
                       				$("#printcontent").html("<p class='bg-success'>用户名可用</p>"); 
                        			jump(count); 
                    			} else { 
                        			$('#myModal').modal('hide');
                    			} 
                			}, 1000); 
           				 } 
            		jump(3); 
                    }
                    if(responsedata=="0"){
                    	$("#printcontent").html("<p class='bg-danger'>用户名已存在</p>");
                    }
                }
            };
            $.ajax(options);
            return false;
    	});
        $("#submitbutton").click(function () {
        var datastring="user.ualais="+$("#user\\.ualais").val()+"&"+"user.upassword="+$("#user\\.upassword").val()+"&"+"user.uemail="+$("#user\\.uemail").val();
            var options = {
                url: 'regist.action',
                type: 'post',
                dataType: 'text',
                data: datastring,
                success: function (responsedata) {
                    //if (responsedata.length > 0)
                       // $("#responseText").text(responsedata);
                    $('#myModal').modal('show');
                    if(responsedata=="2"){//注册成功
                    	 function jump(count) { 
                			window.setTimeout(function(){ 
                    			count--; 
                    			if(count > 0) { 
                       				$("#printcontent").html("<p class='bg-success'>注册成功，将在"+count+"秒后进入登录页面</p>"); 
                        			jump(count); 
                    			} else { 
                        			location.href="p_login.action"; 
                    			} 
                			}, 1000); 
           				 } 
            		jump(5); 
                    }
                    if(responsedata=="0"){
                    	$("#printcontent").html("<p class='bg-danger'>注册失败，用户名已存在</p>");
                    }
                }
            };
            $.ajax(options);
            return false;
        });
    });
  	
  </script>
  </head>
<body class="templatemo-bg-image-2" style="">
	<div class="container">
		<div class="col-md-12">			
			<form class="form-horizontal templatemo-contact-form-1" role="form" id="registform" method="post">
				<div class="form-group">
					<div class="col-md-12">
						<h1 class="margin-bottom-15">欢迎您注册乐淘</h1>
						<p>请注意下方 <a href="#">条款声明</a>和<a href="#">隐私政策</a></p>
					</div>
				</div>				
		        <div class="form-group">
		          <div class="col-md-12">		          	
		            <label for="user.ualais" class="control-label">昵称 *</label>
		            <div class="templatemo-input-icon-container">
		            	<i class="fa fa-user"></i>
		            	<input type="text" class="form-control" id="user.ualais" name="user.ualais" placeholder="">
		            </div>		            		            		            
		          </div>              
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
		            <label for="user.uemail" class="control-label">邮箱 *</label>
		            <div class="templatemo-input-icon-container">
		            	<i class="fa fa-envelope-o"></i>
		            	<input type="email" class="form-control" id="user.uemail" name="user.uemail"  placeholder="">
		            </div>
		          </div>
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
		            <label for="user.upassword" class="control-label">密码*</label>
		            <div class="templatemo-input-icon-container">
		            	<i class="fa fa-lock"></i>
		            	<input type="password" class="form-control" id="user.upassword" name="user.upassword" placeholder="">
		            </div>
		          </div>
		        </div>
		        
		        <div class="form-group">
		          <div class="col-md-12">
		            <label for="confirmpassword" class="control-label">确认密码*</label>
		            <div class="templatemo-input-icon-container">
		            	<i class="fa fa-lock"></i>
		            	<input type="password" class="form-control" id="confirmpassword" placeholder="">
		            </div>
		          </div>
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
		            <div class="checkbox">
		                <label>
		                  <input type="checkbox"> 同意 <a href="#">条款声明</a>和 <a href="#">隐私政策</a>
		                </label>
		            </div>		            
		          </div>
		        </div>
		        <div class="form-group">
		          <div class="col-md-12">
		            <input type="submit" id="submitbutton" value="点击注册" class="btn btn-success pull-right">
		          </div>
		        </div>		    	
		      </form>	
		      <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
   				<div class="modal-dialog">
      				<div class="modal-content">
         				<div class="modal-header">
            				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                  					×
            				</button>
            				<h4 class="modal-title" id="myModalLabel">提示</h4>
       					</div>
         				<div class="modal-body" id="printcontent"></div>
         				<div class="modal-footer">
            				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
         				</div>
      				</div><!-- /.modal-content -->
				</div><!-- /.modal -->
			</div>	  	      
		</div>
	<iframe id="tmp_downloadhelper_iframe" style="display: none;"></iframe></div>


</body>
</html>
